package org.turbobytes.unikey.generator.table;

import static org.turbobytes.unikey.util.ConfigurationUtil.setConfigurationValue;
import static org.turbobytes.unikey.generator.table.TableConstant.*;
import java.util.Properties;

/**
 * Strongly typed configuration values for Table Based Id Generator strategy.
 * This class separates 
 *
 * @author Ganeshji Marwaha
 * @since Aug 14, 2010
 */
public class TableConfiguration {

  // Instance fields for all the configurable properties for this IdGenerator strategy
  private Long initialValue;
  private Long incrementBy;
  private Long batchSize;
  private boolean createTable;
  private String table;
  private String contextNameColumn;
  private String lastValueColumn;

  public TableConfiguration(Properties configuration) {
    setConfigurationValue(this, INITIAL_VALUE,              configuration.getProperty(INITIAL_VALUE));
    setConfigurationValue(this, INCREMENT_BY,               configuration.getProperty(INCREMENT_BY));
    setConfigurationValue(this, BATCH_SIZE,                 configuration.getProperty(BATCH_SIZE));
    setConfigurationValue(this, CREATE_TABLE,               configuration.getProperty(CREATE_TABLE));
    setConfigurationValue(this, TABLE,                      configuration.getProperty(TABLE));
    setConfigurationValue(this, CONTEXT_NAME_COLUMN,        configuration.getProperty(CONTEXT_NAME_COLUMN));
    setConfigurationValue(this, LAST_VALUE_COLUMN,          configuration.getProperty(LAST_VALUE_COLUMN));
  }
  
  public Long getInitialValue() {
    return initialValue;
  }
  public Long getIncrementBy() {
    return incrementBy;
  }
  public Long getBatchSize() {
    return batchSize;
  }
  public boolean isCreateTable() {
    return createTable;
  }
  public String getTable() {
    return table;
  }
  public String getContextNameColumn() {
    return contextNameColumn;
  }
  public String getLastValueColumn() {
    return lastValueColumn;
  }
}
